package com.elive.controller.backend;

import com.elive.common.Const;
import com.elive.common.ServerResponse;
import com.elive.pojo.User;
import com.elive.service.IServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * Created by wuyin on 2018/3/13.
 */
@Controller
@RequestMapping("/service")
public class ServiceController {

    @Autowired
    private IServiceService iServiceService;

    @RequestMapping(value = "getServiceList.do", method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse getDeviceList(HttpSession session, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum, @RequestParam(value = "pageSize",defaultValue = "10") int pageSize){
        User user = (User) session.getAttribute(Const.CURRENT_USER);
        if(user == null){
            return ServerResponse.createByErrorMessage("用户未登录");
        }

        return iServiceService.getServiceList(pageNum,pageSize);

    }

}
